package com.example.lvsuo.controller;


import com.example.lvsuo.entity.CwInout;
import com.example.lvsuo.entity.vo.xzhvo.CwInoutVo;
import com.example.lvsuo.modal.Result;
import com.example.lvsuo.service.ICwInoutService;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 心心念念
 * @since 2021-03-30
 */
@RestController
@RequestMapping("/cwInout")
public class CwInoutController {
    //调用service接口
    @Autowired
    ICwInoutService  inoutService;

    @GetMapping
    public Result Getlists(CwInoutVo cwinoutvo) {
             //使用分页插件 传入  当前页 和当前页需要显示多少条
        PageHelper.startPage(cwinoutvo.getCurrentPage(), cwinoutvo.getPageSize());
        //获取所有数据 交给pageinfo插件进行封装
        PageInfo pageInfo = new PageInfo(inoutService.Getlists(cwinoutvo));
        //返回数据
        return Result.back(pageInfo);

    }

     //全所收支明细

    @GetMapping("/quansuo")
    public Result quansuo(CwInoutVo cwinoutvo) {
        //使用分页插件 传入  当前页 和当前页需要显示多少条
        PageHelper.startPage(cwinoutvo.getCurrentPage(), cwinoutvo.getPageSize());
        //获取所有数据 交给pageinfo插件进行封装
        PageInfo pageInfo = new PageInfo(inoutService.quansuo(cwinoutvo));
        //返回数据
        return Result.back(pageInfo);

    }



    @GetMapping("shouru")
    public  Result   get(CwInoutVo cwinoutvo){

        return   Result.back(inoutService.get(cwinoutvo));
    }

    @PostMapping
    public  Result   add(@RequestBody  CwInout cwinout){

        return   Result.back(inoutService.save(cwinout));
    }

    @GetMapping("shouruticheng")
    public  Result   shouruticheng(CwInoutVo cwinoutvo){

        return   Result.back(inoutService.shouruticheng(cwinoutvo));
    }




}